package com.beici.waterghost.controller;


import com.beici.waterghost.mapper.albumMapper;
import com.beici.waterghost.model.resultes;
import com.beici.waterghost.model.user;
import com.beici.waterghost.service.impl.ablumServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/album")
@CrossOrigin
public class albumController {
    @Autowired
    private ablumServiceImpl albumService;

    @GetMapping("/albums")
    public resultes getAblums(){
        return albumService.quertyTagInfo();
    }

    @GetMapping("/albumsorder")
    public resultes getAlbumOrder(){
        return albumService.quertyLookSort();
    }

    @GetMapping("/albumdetails/{abId}")
    public resultes getAlbumDetails(@PathVariable("abId") Long abId){
      return   albumService.quertyDetilsTag(abId);
    }

    @PutMapping("/album")
    public resultes putAlbum(HttpServletRequest request,String abName,String abMess){
        user u = (user) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return albumService.addAlbum(u.getUserId(),request.getRemoteHost(),abName,abMess);
    }

    @GetMapping("/albumall")
    public resultes getAlbumAll(){
        return albumService.getAlbumAll();
    }
}
